<?php
	session_start();
	include '../../lib/common/dbRoutines.php';
	include '../../lib/dao/UserDao.php';

	$username = $_POST['username'];
	$pass = md5(md5(trim($_POST['pass'])));
	
	$answer = "error";
	
	if(!isset($_SESSION['user'])){
		$conn = getDbConnection();  
		$userDao = new UserDao($conn); 
		
		$result = $userDao->login($username,$pass);
		if($result){
			$_SESSION['user'] = $username;
			$_SESSION['pass'] = $pass;
			$answer = true;
		}
	}
	echo $answer;

?>